<template>
	<view>
		<view>
			<view class="title">{{`系统已为${setMobile}发送了短信验证码`}}</view>
		</view>
		<view class="input">
			<input type="text" value="" v-model="code" placeholder="请输入验证码">
		</view>
		<button class="btn" @click="next">下一步</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile:uni.getStorageSync('userinfo').mobile,
				setMobile:'',
				code:''
			}
		},
		onShow() {
			this.saveCode();
			this.setMobile = this.mobile.replace(this.mobile.substring(3,7), "****")
		},
		methods: {
			next(){
				console.log(this.mobile,"用户手机1111111111");
				this.https('/login/codeCheck', {
					mobile:this.mobile,
					code:this.code
				}).then(res => {
					uni.showToast({
						title:res.msg,
						icon:'none',
						duration:1500
					})
					setTimeout(()=>{
						uni.navigateTo({
							url:'../editpassword/editpassword?mobile=' + this.mobile
						})
						
					})
					
				}).catch(err=>{
					uni.showToast({
						title:err.msg,
						icon:'none',
						duration:1500,
						success() {
							
						}
					})
				})
			},
			saveCode(){
				this.https('/login/code', {
					mobile:this.mobile
				}).then(res => {
					uni.showToast({
						title:res.msg,
						icon:'success',
						duration:1500
					})
				}).catch(err=>{
					uni.showToast({
						title:err.msg,
						icon:'error',
						duration:1500
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.title{
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #222222;
		display: flex;
		justify-content: center;
		margin-top: 300rpx;
	}
	.input{
		width: 646rpx;
		margin: 0 auto;
		height: 100rpx;
		margin-top: 70rpx;
		border-bottom: solid 2rpx #DDE0E4;
		display: flex;
		align-items: center;
		input{
			padding: 20rpx 0rpx 0rpx 0rpx;
			margin-top: 20rpx;
			font-size: 28rpx;
			width: 80%;
			color: #222222;
		}
	}
	.btn{
		width: 630rpx;
		height: 80rpx;
		background: #45bb52;
		border-radius: 16rpx;
		color: #FFF;
		margin-top: 120rpx;
		font-size: 32rpx;
		line-height: 80rpx;
		background: linear-gradient(90deg, #45bb52 0%, #45BCD9 100%);
	}
</style>
